#!/usr/bin/perl -T
# report.pl
use warnings;
# lack of use strict

use CGI qw( :standard *table *ul);
use Lingua::EN::Syllable;
use Lingua::EN::Nickname;
use Lingua::EN::Fathom;
 

print header, start_html(-bgcolor => white, -title => "Reporting");

if (!param(report)) {
   print start_table({bgcolor => lightblue, 
                      cellspacing => 0, cellpadding => 5}), start_form,
   Tr(td(["Name" , textfield('name')])), "\n",
   Tr(td(["Report" , textarea('report')])), "\n",
   Tr(td({colspan => 2, align => center}, submit())),
   end_form, end_table;

} else {
   my $text = new Lingua::EN::Fathom;
   $text->analyse_block(param(report));
   my $numSyll = syllable(param(report));
   print h1("Received report by ", nickroot(param(name)), ":"),
   p(em(param(report))),
   p("Which has received the following ratings"),
   start_ul, li("Fog = ", $text->fog),
   li("Kincaid = ", $text->kincaid),
   li("Flesch = ", $text->flesch),
   end_ul,
   p("And you will be paid ", $numSyll*0.25,
     "\$ for $numSyll syllables"),
}
print end_html;
